# 字典的定义-------------------------------------------------------------
# 同样使用{}, 不过存储的是一个个键值对
demo_dict1 = {
    "key1": "value1",
    "key2": "value2",
    "key3": "value3",
}
demo_dict2 = dict()
# key值不可重复，value值可以重复

# 通过key获取value
print(demo_dict1["key1"])   # 类似下标索引

# 通过key修改value
demo_dict1['key1'] = 'update_value1'

# 嵌套字典
demo_dict3 = {
    "chen": {
        "name": "chen",
        "age": 18,
        "gender": "male"
    },
    "jiang":{
        "name": "jiang",
        "age": 28,
        "gender": "male"
    }
}
print(demo_dict3["chen"]["age"])

# 字典的操作-------------------------------------------------------------
# 1.增
demo_dict1["chen"] = "yan"  # 其实和修改语法一致，当key存在则修改，key不存在则新增

# 2.删
#根据key删除的同时取出key所对应的value值
temp = demo_dict1.pop("chen")
print(temp)

# 3.查询
#拿到字典的全部key值
keys = demo_dict1.keys()
for key in keys:
    print(key, demo_dict1[key])

# 综合案例-------------------------------------------------------------
employee_list = {
    "王力宏":{
        "部门":"科技部",
        "工资":"3000",
        "级别":"1"
    },
    "周杰伦":{
        "部门":"市场部",
        "工资":"5000",
        "级别":"2"
    },
    "张雪友":{
        "部门":"科技部",
        "工资":"4000",
        "级别":"1"
    },
    "刘德华":{
        "部门":"市场部",
        "工资":"6000",
        "级别":"2"
    },
    "林俊杰":{
        "部门":"市场部",
        "工资":"7000",
        "级别":"3"
    }
}
# 通过for循环，对所有级别为1级的员工，级别上升1级，薪水增加1000元
for item in employee_list.values():
    if item['级别'] == "1":
        item["工资"] = str(int(item["工资"]) + 1000)
print(employee_list)